var a = require("../../../../@babel/runtime/helpers/defineProperty"), t = getApp();

Page({
    data: {
        active: 0,
        dataList: [],
        loading: !1
    },
    onLoad: function(a) {
        this.initTab();
    },
    initTab: function() {
        var a = this;
        this.data.dataList = [], [ {
            name: "全部",
            value: 0
        }, {
            name: "发放",
            value: 1
        }, {
            name: "使用",
            value: 2
        }, {
            name: "退回",
            value: -1
        }, {
            name: "过期",
            value: -2
        } ].forEach(function(t, e) {
            a.data.dataList.push({
                name: t.name,
                param: {
                    detail_type: t.value
                },
                isLoadMore: !0,
                page: 1,
                total_page: 0,
                list: []
            });
        }), this.setData({
            dataList: this.data.dataList
        }), this.getData();
    },
    changeTab: function(a) {
        this.setData({
            active: a.detail.index
        }), this.data.dataList[this.data.active].list.length > 0 || this.getData();
    },
    getData: function() {
        var e = this;
        t._getNetWork({
            url: t.getNetAddresss("plugin.ywm-fight-groups.frontend.controllers.open-card-detail.get-open-card-detail"),
            data: {
                detail_type: this.data.dataList[this.data.active].param.detail_type
            },
            success: function(i) {
                var d = i.data;
                1 == d.result ? (e.data.dataList[e.data.active].total_page = d.data.last_page, e.data.dataList[e.data.active].page = e.data.dataList[e.data.active].page, 
                e.setData(a({}, "dataList[" + e.data.active + "].list", d.data.data))) : t.tips(d.msg);
            }
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.data.dataList[this.data.active].isLoadMore ? this._getMoreData() : console.log("没有更多数据");
    },
    _getMoreData: function() {
        var e = this;
        if (this.data.dataList[this.data.active].isLoadMore = !1, !(this.data.dataList[this.data.active].page >= this.data.dataList[this.data.active].total_page)) {
            var i = this.data.dataList[this.data.active].page + 1, d = t.getNetAddresss("plugin.ywm-fight-groups.frontend.controllers.open-card-detail.get-open-card-detail");
            d = d + "&page=" + i, t._getNetWork({
                url: d,
                data: {
                    detail_type: this.data.dataList[this.data.active].param.detail_type
                },
                success: function(t) {
                    var d = t.data;
                    if (1 == d.result) {
                        var s = d.data.data;
                        e.data.dataList[e.data.active].isLoadMore = !0, e.data.dataList[e.data.active].page = i, 
                        e.setData(a({}, "dataList[" + e.data.active + "].list", e.data.dataList[e.data.active].list.concat(s)));
                    } else e.data.dataList[e.data.active].isLoadMore = !1;
                },
                fail: function(a) {
                    console.log(a);
                }
            });
        }
    },
    onShareAppMessage: function() {}
});